home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / clipper / ks94an.zip / 2COMP.HDR < prev    next >
Text File  |  1994-04-25  |  873b  |  40 lines

  1. /******************************************************************************
  2.                  The Klipper Library, for CA-Clipper 5.x
  3.         Copyright (c), 1994, Wallace Information Systems Engineering
  4.  
  5. FUNCTION:
  6.  
  7. _2Comp( cBinNum ) --> c2CompStr
  8.  
  9. PARAMETERS:
  10.  
  11. cBinNum : Character String - Binary Number to 2's complement.
  12.  
  13. SHORT:
  14.  
  15. Perform a binary 2's compliment.
  16.  
  17. DESCRIPTION:
  18.  
  19. _2comp() perfroms a 2's compliment on a binary number.
  20.  
  21. The cBinNum must be passed as a character string in order to preserve
  22. significant leading zeros, because:
  23.  
  24.  
  25. 00101 = 11011 (2's comp) = 27
  26.   101 =   011 (2's comp) =  3
  27.  
  28. The leading zeros are significant in a 2's compliment.
  29.  
  30. NOTE:
  31.  
  32.  
  33.  
  34. EXAMPLE:
  35.  
  36. ? _2comp('11010101') // '00101011'
  37. ? _2comp('010101')   //   '101011'
  38.  
  39. ******************************************************************************/
  40.